﻿using System.Data;

namespace DAL
{
    public static class DalModulesMain
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetModulesMain(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_ModulesMain_Get");
        }
        public static DataTable GetModulesMainEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_ID", id);
            return Cls.GetData("sp_ModulesMain_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtModuleMain obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_Name", obj.ModulesMainName);
            Cls.AddParameter("@Num", obj.Num);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_ModulesMain_Insert");
        }
        public static bool Update(EtModuleMain obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_ID", obj.ModulesMainId);
            Cls.AddParameter("@ModulesMain_Name", obj.ModulesMainName);
            Cls.AddParameter("@Num", obj.Num);
            Cls.AddParameter("@Descripttion", obj.Descripttion);
            return Cls.ExecuteNonQuery("sp_ModulesMain_Update");
        }
        public static bool Delete(EtModuleMain obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ModulesMain_ID", obj.ModulesMainId);
            obj.msg = Cls.ExecuteNonQueryOutput("sp_ModulesMain_Del", "@MSG");
            return true;
        }
        #endregion
    }

    public class EtModuleMain
    {
        public int ModulesMainId { get; set; }
        public string ModulesMainName { get; set; }
        public int Num { get; set; }
        public string Descripttion { get; set; }
        public int msg { get; set; }
    }
}
